package com.tools.hry.xls.analysis.util;

import com.tools.hry.utils.ValidateUtils;

import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by 峥桂 on 2017/9/4.
 */
public class BaseDataChecked {

    private static final Map<String, Integer> baseDataMap = new HashMap<String, Integer>();
    private static final Map<String, String> id_type_map = new HashMap<String, String>();

    static {
        baseDataMap.put("身份证", 1);
        baseDataMap.put("证件号", 2);
        baseDataMap.put("手机", 3);
        baseDataMap.put("邮箱", 4);
        baseDataMap.put("证件类型", 5);

        id_type_map.put("1", "身份证");//
        id_type_map.put("2", "护照");//
        id_type_map.put("3", "军官证");//
        id_type_map.put("4", "港澳居民通行证");//
        id_type_map.put("5", "台湾居民通行证");//
        id_type_map.put("6", "其他");//
    }


    public static String checkBaseData(String columnName, Object columnVaule) {
        String message = "";
        try {
            Integer i = baseDataMap.get(columnName);
            if (i == null) {
                return "";
            }
            switch (i) {
                case 1: case 2:
                    message = ValidateUtils.validateIDCard(columnVaule.toString());
                    break;
                case 3:
                    message = ValidateUtils.validatePhoneNum("2", columnVaule.toString());
                    break;
                case 4:
                    message = ValidateUtils.validateEmail(columnVaule.toString());
                    break;
                case 5:
                    String idCardType = id_type_map.get(columnVaule.toString());
                    if("".equals(idCardType)||idCardType.length()==0){
                        message= "证件类型不存在";
                    }
                    break;
                default:
            }
        } catch (ParseException e) {}
        return message;
    }

    public static void main(String[] args) {
        System.out.println(checkBaseData("邮箱", "234234@121.com"));
        System.out.println(checkBaseData("证件", "360732199401251540"));
        System.out.println(checkBaseData("手机", "15345678911"));
    }

}
